Add Filecoin DX toolkit, examples, and architecture docs#1260
Add Filecoin DX toolkit, examples, and architecture docs#1260GautamBytes wants to merge 16 commits intolibp2p:mainfrom
Conversation
99e9475 to
be6030a
Compare
PR #1260 Review — Filecoin DX ToolkitThe changes and module architecture is clean, tests are solid, and the parity matrix + dependency tree documentation is really impressive work. Few Issues I found during review1. Duck-typing in
|
|
sure , will go through this and do the suggested changes soon! |
Dm over discord once, couldn't find the ID |
done , just sent the dm! |
187dc73 to
fca6d25
Compare
2fab5d9 to
245b377
Compare
|
Hello @GautamBytes, thanks for this PR Full review here: PR #1260 Review — Filecoin DX toolkit, examples, and architecture docs1. Summary of Changes
2. Branch Sync Status and Merge ConflictsBranch Sync Status
Merge Conflict Analysis
3. Strengths
4. Issues FoundCritical
Major
Minor
5. Security Review
No other clear key-management/crypto/input-validation regressions observed in the new Filecoin modules. 6. Documentation and Examples
7. Newsfragment Requirement
8. Tests and ValidationArtifacts saved under
Observation: current tests pass because they encode the raise-on-malformed-IWANT behavior; this is exactly where robustness should be changed. 9. Recommendations for Improvement
10. Questions for the Author
11. Overall Assessment
Primary blockers are: (1) malformed IWANT handling still raises; (2) merge conflict with |
|
will do the suggested changes soon @acul71 |
…bytes_from_hex utility
Signed-off-by: Gautam Manchandani <gautammanch@Gautams-MacBook-Air.local>
Signed-off-by: Gautam Manchandani <gautammanch@Gautams-MacBook-Air.local>
8c7070d to
32ca8dc
Compare
|
thanks @GautamBytes for the mods. PR #1260 Review — Filecoin DX toolkit, examples, and architecture docs1. Summary of Changes
2. Branch Sync Status and Merge ConflictsBranch Sync Status
Merge Conflict Analysis
3. Strengths
4. Issues FoundCritical
msg_ids: list[bytes] = []
for msg_id_str in iwant_msg.messageIDs:
mid_bytes = safe_bytes_from_hex(msg_id_str)
if mid_bytes is None:
logger.warning(...)
continue
msg_ids.append(mid_bytes)
# ... build packet ...
packet.publish.extend(msgs_to_forward)
self.send_rpc(sender_peer_id, packet)
mock_write_msg = AsyncMock()
monkeypatch.setattr(gossipsubs[index_bob].pubsub, "write_msg", mock_write_msg)
iwant_msg = rpc_pb2.ControlIWant(messageIDs=["not_a_valid_msg_id", valid_msg_id])
await gossipsubs[index_bob].handle_iwant(iwant_msg, id_alice)
mock_mcache_get.assert_called_once_with(valid_mid)
mock_write_msg.assert_called_once()
mock_send_rpc = MagicMock()
monkeypatch.setattr(gossipsubs[index_bob], "send_rpc", mock_send_rpc)
iwant_msg = rpc_pb2.ControlIWant(messageIDs=["not_a_valid_msg_id", valid_msg_id])
await gossipsubs[index_bob].handle_iwant(iwant_msg, id_alice)
# invalid ID skipped; only valid ID looked up
mock_mcache_get.assert_called_once_with(valid_mid)
# response goes through router RPC path
mock_send_rpc.assert_called_once()
called_peer_id, packet = mock_send_rpc.call_args[0]
assert called_peer_id == id_alice
assert isinstance(packet, rpc_pb2.RPC)
assert len(packet.publish) == 1
assert packet.publish[0] == test_messageMajor
Minor
# preferred
class SpecVector(TypedDict, total=False):
file: str
name: str
valid: bool
error: str
value: str
TEST_VECTORS: dict[str, SpecVector] = {...}
# alternative
class TestVector(TypedDict, total=False):
__test__ = False
file: str
name: str
valid: bool
error: str
value: str
5. Security Review
No new obvious key-management, serialization, or transport-security regressions were identified in the added Filecoin DX modules. 6. Documentation and Examples
7. Newsfragment Requirement
8. Tests and Validation
9. Recommendations for Improvement
10. Questions for the Author
11. Overall Assessment
Primary blocker is the current failing test in |
Accept byte-form wire IDs in the parser path while preserving canonical hex handling for string IDs, preventing control-path crashes from mixed peer payload formats and keeping demo pubsub flows stable. Made-with: Cursor
|
@GautamBytes @yashksaini-coder Quick update on the pubsub demo failures and the IHAVE/IWANT message ID handling. I reproduced the issue in Filecoin pubsub demos: they were crashing in Root causeOur What was fixed
Validation
Protobuf/spec noteThere is still a cross-implementation/provenance nuance:
So this fix is an interoperability hardening at the parser boundary (safe now), while a longer-term discussion could be whether to align schema more strictly with current spec direction. |
|
Is this ready to be merged ? |
Hey sorry for late reply , It seems good to me now. tagging @seetadev for final review |
Summary
This PR adds a dedicated Filecoin developer-experience layer to py-libp2p, including pinned protocol/topic/bootstrap constants, practical bootstrap/runtime helpers, reusable pubsub presets, CLI tooling, runnable examples, architecture-positioning docs, and traceability artifacts.
##Closes: #1279
Why
Filecoin developers need a low-friction Python path for diagnostics, tooling, analytics, testnet work, and research workflows without implementing full node behavior. This PR provides that DX layer while documenting clear boundaries for where Lotus/Forest remain required.
What changed
libp2p.filecoinpackage:python -m libp2p.filecoinsupportfilecoin-dxfilecoin-connect-demofilecoin-ping-identify-demofilecoin-pubsub-demoValidation
Ran locally:
python -m tox run -e py312-lint(includes pre-commit, ruff, mypy, pyrefly) -> passpython -m pytest -p no:rerunfailures tests/core/filecoin -q-> 37 passedsphinx-build -b html docs docs/_build/html-> succeededtopics/bootstrap/preset) -> expected outputsNotes